package com.example.qcrmdemo.service.impl;

import com.example.qcrmdemo.dao.CustomerMapper;
import com.example.qcrmdemo.entity.Customer;
import com.example.qcrmdemo.service.CustomerService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    private CustomerMapper customerMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean append(Customer customer) {
        return customerMapper.insertCus(customer)>0;
    }

//    @Override
//    public PageInfo<Customer> findAll(int pageNum, int pageSize) {
//        return null;
//    }

//    @Override
//    public PageInfo<Customer> findByKeyword(int pageNum, int pageSize, String keyword) {
//        return null;
//    }

//    @Override
//    public Customer findById(int id) {
//        return null;
//    }

//    @Override
//    public boolean modify(Customer customer) {
//        return false;
//    }

//    @Override
//    public boolean remove(int id) {
//        return false;
//    }

    @Override
    public PageInfo<Customer> selectAll() {
        List<Customer> customers = customerMapper.selectAll();
        PageInfo<Customer> pageInfo =new PageInfo<>(customers);
        return pageInfo;

    }
}
